package com.woniuxy.portal.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.DateFormat;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

/**
 * <p>
 *
 * </p>
 *
 * @author 作者
 * @since 2023-09-15
 */
@Getter
@Setter
@TableName("t_book")
@ApiModel(value = "Book对象", description = "")
// 指定es索引库名称
@Document(indexName = "books")
@ToString
public class Book implements Serializable {

    private static final long serialVersionUID = 1L;

    // 指定es中文件的主键id
    @Id
    private Long id;
    // 指定es的分词器与字段类型(json的key的类型)
    @Field(analyzer = "ik_max_word",type = FieldType.Text)
    private String name;
    @Field(type = FieldType.Integer)
    private Integer typeId;
    @Field(analyzer = "ik_smart",type = FieldType.Text)
    private String provider;
    // 类型指定为keyword表示字符串类型、不分词
    @Field(type = FieldType.Keyword)
    private String author;
    @Field(type = FieldType.Double)
    private BigDecimal price;
    @Field(analyzer = "ik_smart",type = FieldType.Text)
    private String detail;
    @Field(type = FieldType.Keyword)
    private String imgsrc;
    @Field(type = FieldType.Integer)
    private Integer collectioncount;
    @Field(type = FieldType.Integer)
    private Integer storecount;
    @Field(type = FieldType.Integer)
    private Integer buycount;
    @Field(type = FieldType.Integer)
    private Integer readcount;
    @Field(type = FieldType.Date,format = DateFormat.custom,pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createtime;
    @Field(type = FieldType.Date,format = DateFormat.custom,pattern = "yyyy-MM-dd HH:mm:ss")
    private Date updatetime;
    @Field(type = FieldType.Integer)
    private Integer state;
    @Field(type = FieldType.Integer)
    private Integer version;
}
